<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>阻止冒泡</title>
    <style>
        #parent{
            height: 500px;
            width: 500px;
            border: 2px solid #000;
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 100px auto;
        }
        #son {
            height: 200px;
            width: 200px;
            border: 2px solid #000;
        }
    </style>
</head>
<body>
    <div id="parent">
        <div id="son"></div>
    </div>
    <script>
        const parentEle = document.getElementById('parent')
        const sonEle = document.getElementById('son')

        sonEle.addEventListener('click',function(){
            console.log('son');
            event.stopPropagation();
        })

        parentEle.addEventListener('click',function(){
            console.log('parent');
        })

    </script>
</body>
</html>